Import mojo

Import diddy
Import diddy.functions
Import inputbutton



Class NumberButtonsBonus1
	Field x:float
	Field y:float
	Field width
	Field height
	Field buttonWidth
	Field buttonHeight
	Field highlightNumber = 0
	Field rows:Int = 5
	Field columns:Int = 2
	Field inputNumber:String

	Field images:GameImage
	Field buttonsList:ArrayList<InputButton> = New ArrayList<InputButton>
	
	Method New(x,y, _width:Int, _height:Int)
		Local number:Int = 0
		Local buttonWidth4:Float = _width/4
		Local rowIncrement:Float = _height/rows
		Local columnIncrement:Float = _width/columns
		
		self.x = x
		self.y = y
		width = _width
		height = _height	
		
		buttonHeight = 65
		buttonWidth = 65
	
		For Local rowY:Int = 1 To rows
		For Local columnX:Int = 1 To columns
		
		Local button1:InputButton = InputButton.Create(game.images.Find("numbersStrip"),(columnX*columnIncrement)-(columnIncrement/2)+x, (rowY*rowIncrement)-(rowIncrement/2)+y, New NumberButton(number, self), number, buttonsList)

		button1.hoverImage = 14
		number += 1
		Next
		Next
		
	
		
	End
	
	
	Method Update:void()
		InputButton.UpdateAll(buttonsList)
	End
	
	Method Render()	
		PushMatrix	
		SetAlpha (0.6)
		SetColor(0,0,0)
		DrawRect(x,y, width, height )
		PopMatrix
		InputButton.DrawAll(buttonsList)
	End
	
	Method Clear:Void()

		inputNumber = ""

	End
	Method GetInputAsString:String(_input:Int)
	
	Select _input
		Case 10
			Return "0"
		Case 11
			Return "+"
		Case 12
			Return "-"
		Case 13
			Return "GO!"
		Case 14
			Return "C"	
		Case 15
			Return ""		
		Default
			Return _input
	End
	
	End
	
End

Class NumberButton Extends ButtonEvent
	Field symbol:Int
	Field parent:NumberButtonsBonus1
	
	Method New(symbol:Int, parent:NumberButtonsBonus1)
		Self.symbol=symbol
		Self.parent = parent
	End
	
	Method OnClicked:Void()
		parent.inputNumber=symbol
	End
End









